package com.yhy.wxzn.wcs.device.plc.bean;

import com.yhy.wxzn.common.utils.SpringUtil;
import lombok.Data;
import org.jeecg.common.util.RedisUtil;

@Data
public class XJPHoistPlc extends BasePlc {

    private volatile int taskNoR;

    private volatile int layer;

    //1:自动模式 2:手动模式 3:维修模式
    private volatile int status;
    //1:执行中(有任务在执行) 2:暂停(有任务暂停) 3:空闲(任务结束无任务)
    private volatile int workStatus;
    //1:空 2:有货
    private volatile int isHaveCargo;
    //1:空 2:有车
    private volatile int isHaveCar;

    //1.任务完成  2.强制完成
    private volatile int taskStatus;

    //--------------------------------------------提升机写信息--------------------------------------------------------
    //起始层
    private volatile int sourceFloor;
    //目标层
    private volatile int targetFloor;
    //任务类型
    private volatile int taskType;
    //任务号
    private volatile int taskNoW;
    //小车出入提升完成  1:上车完成 2:下车完成
    private volatile int carIntoOrLeaveLifterFinished;
    //发送1
    private volatile int taskStart;
    //发送1
    private volatile int taskEnd;



    private static final String LIFTER_TASK_NO = "LIFTER_TASK_NO";

    public synchronized static int getAutoIncrementLiferTaskNo(){
        RedisUtil redisUtil = SpringUtil.getBean(RedisUtil.class);
        if (redisUtil.get(LIFTER_TASK_NO) == null || (int)redisUtil.get(LIFTER_TASK_NO) == 99999){
            redisUtil.set(LIFTER_TASK_NO,1);
            return 1;
        }
        return (int) redisUtil.incr(LIFTER_TASK_NO, 1);


    }


    public boolean getIsHaveCargo() {
        return isHaveCargo == 2;
    }
}
